package com.sxf.core.db.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @description: 数据源配置项
 * @author: Leo
 * @date:
 */
@Configuration
@ConfigurationProperties(DatasourceProperties.PREFIX)
public class DatasourceProperties {

    static final String PREFIX = "sxf.datasource";

    /**
     * 最小空闲连接数量
     */
    private int minimumIdle = 10;

    /**
     * 连接池最大连接数，默认是10
     */
    private int maximumPoolSize = 50;

    /**
     * 此属性控制从池返回的连接的默认自动提交行为,默认值：true
     */
    private boolean autoCommit = true;

    /**
     * 空闲连接存活最大时间，默认600000（10分钟）
     */
    private int idleTimeout = 30000;

    /**
     * 连接池名字
     */
    private String poolName = "sxfHikariCP";

    /**
     * 此属性控制池中连接的最长生命周期，值0表示无限生命周期，默认1800000即30分钟
     */
    private int maxLifetime = 60000;

    /**
     * 数据库连接超时时间,默认30秒，即30000
     */
    private int connectionTimeout = 60000;

    /**
     * 测试
     */
    private String connectionTestQuery = "SELECT 1";

    /**
     * 配置文件信息
     */
    private String configLocation = "classpath:mybatis.xml";

    /**
     * xml位置信息
     */
    private String mapperLocations = "classpath*:mapper/*.xml";

    /**
     * DDL
     */
    private List<String> schema;

    /**
     * DML
     */
    private List<String> data;

    private DbProperties read;
    private DbProperties write;

    public int getMinimumIdle() {
        return minimumIdle;
    }

    public void setMinimumIdle(int minimumIdle) {
        this.minimumIdle = minimumIdle;
    }

    public int getMaximumPoolSize() {
        return maximumPoolSize;
    }

    public void setMaximumPoolSize(int maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }

    public boolean isAutoCommit() {
        return autoCommit;
    }

    public void setAutoCommit(boolean autoCommit) {
        this.autoCommit = autoCommit;
    }

    public int getIdleTimeout() {
        return idleTimeout;
    }

    public void setIdleTimeout(int idleTimeout) {
        this.idleTimeout = idleTimeout;
    }

    public String getPoolName() {
        return poolName;
    }

    public void setPoolName(String poolName) {
        this.poolName = poolName;
    }

    public int getMaxLifetime() {
        return maxLifetime;
    }

    public void setMaxLifetime(int maxLifetime) {
        this.maxLifetime = maxLifetime;
    }

    public int getConnectionTimeout() {
        return connectionTimeout;
    }

    public void setConnectionTimeout(int connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }

    public String getConnectionTestQuery() {
        return connectionTestQuery;
    }

    public void setConnectionTestQuery(String connectionTestQuery) {
        this.connectionTestQuery = connectionTestQuery;
    }

    public String getConfigLocation() {
        return configLocation;
    }

    public void setConfigLocation(String configLocation) {
        this.configLocation = configLocation;
    }

    public String getMapperLocations() {
        return mapperLocations;
    }

    public void setMapperLocations(String mapperLocations) {
        this.mapperLocations = mapperLocations;
    }

    public DbProperties getRead() {
        return read;
    }

    public void setRead(DbProperties read) {
        this.read = read;
    }

    public DbProperties getWrite() {
        return write;
    }

    public void setWrite(DbProperties write) {
        this.write = write;
    }

    public List<String> getSchema() {
        return schema;
    }

    public void setSchema(List<String> schema) {
        this.schema = schema;
    }

    public List<String> getData() {
        return data;
    }

    public void setData(List<String> data) {
        this.data = data;
    }

}
